//
//  FZXPayCell.m
//  SimulationShow
//
//  Created by apple on 2018/6/27.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "FZXPayCell.h"
#define ScreenSizeWidth ([UIScreen mainScreen].bounds.size.width)
#define ScreenSizeHeight ([UIScreen mainScreen].bounds.size.height)
#define cellHeight  50
@implementation FZXPayCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setupUI];
    }
    return self;
}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifferCell = @"FZXPayCell";
    FZXPayCell *cell = [tableView dequeueReusableCellWithIdentifier:identifferCell];
    if (!cell) {
        cell = [[FZXPayCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifferCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    
    
    return cell;
}
- (void)setupUI{
//    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, ScreenSizeWidth-50, cellHeight)];
//    self.titleLabel.textColor = [UIColor darkGrayColor];
//
//    self.titleLabel.font = [UIFont systemFontOfSize:16];
//    [self.contentView addSubview:self.titleLabel];
    self.backgroundColor = [UIColor whiteColor];
    self.icon = [[UIImageView alloc] init];
    self.icon.image = [UIImage imageNamed:@"weixinhh"];
    [self.contentView addSubview:self.icon];
    [self.icon makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16*kScaleFit);

        make.size.mas_equalTo(CGSizeMake(20*kScaleFit, 20*kScaleFit));
        make.centerY.mas_equalTo(self.contentView);
    }];
    //    杨雪莉baby"
    self.titleLab = [UILabel labelWithText:@"余额" andTextColor:rgb(51,51,51) andName:nil andFontSize:15*kScaleFit];
    
    [self.contentView addSubview:self.titleLab];
    [self.titleLab makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.icon.mas_right).mas_equalTo(7*kScaleFit);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
    self.detailLab = [UILabel labelWithText:@"(¥ 120.00)" andTextColor:rgb(51,51,51) andName:nil andFontSize:15*kScaleFit];
    self.detailLab.hidden = YES;
    [self.contentView addSubview:self.detailLab];
    [self.detailLab makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.titleLab.mas_right).mas_equalTo(18*kScaleFit);
        make.centerY.mas_equalTo(self.contentView);
    }];
    //

    
//    UIView *lineView = [UIView new];
//    lineView.backgroundColor = rgb(51,51,51);
//    [self.contentView addSubview:lineView];
//    [lineView makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(16*kScaleFit);
//        make.right.mas_equalTo(-16*kScaleFit);
//        make.bottom.mas_equalTo(0);
//        make.height.mas_equalTo(0.5*kScaleFit);
//    }];
    
    self.selectBtn = [[UIButton alloc] init];//WithFrame:CGRectMake(0, 0, 50, 50)];
    [self.contentView addSubview:self.selectBtn];
    [self.selectBtn makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15*kScaleFit);
        make.centerY.mas_equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(50*kScaleFit, 50*kScaleFit));
    }];
    [self.selectBtn addTarget:self action:@selector(selectPressed:) forControlEvents:UIControlEventTouchUpInside];
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (void)selectPressed:(UIButton *)sender{
    self.isSelect = !self.isSelect;
    if (self.qhxSelectBlock) {
        self.qhxSelectBlock(self.isSelect, sender.tag);
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
